/**
 * 
 */
package com.risetek.tft.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.risetek.tft.entity.TSysConfig;
import com.risetek.tft.service.SysconfigService;
import com.zlinepay.framework.bean.AjaxJson;
import com.zlinepay.framework.web.util.RequestUtils;


/**
 * @author hetao
 * 
 */
@Controller
@RequestMapping("/sys")
public class SysAction extends BaseAction {

	@RequestMapping(value = "/edit.action")
	public String edit(ModelMap model) {
		return "sys/edit";
	}
	
	@RequestMapping(value = "/save.action")
	@ResponseBody
	public AjaxJson save(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception {
		AjaxJson json = new AjaxJson();
		Map map = RequestUtils.getRequestMap(request);
		TSysConfig config = sysconfigService.findById(1);
		if(config == null) {
			config = new TSysConfig();
		}
		config.setConfig(map);
		sysconfigService.saveOrUpdate(config);
		json.setSuccess(true);
		json.setMsg("保存成功！");
		return json;
	}
	
	@Autowired
	private SysconfigService sysconfigService;

}
